(global.webpackJsonp = global.webpackJsonp || []).push([ [ "pages/components/poster/index" ], {
    "1ef0": function(t, e, n) {},
    2818: function(t, e, n) {
        n.r(e);
        var r = n("5ff5"), i = n("859f");
        for (var a in i) [ "default" ].indexOf(a) < 0 && function(t) {
            n.d(e, t, function() {
                return i[t];
            });
        }(a);
        n("b446");
        var o = n("f0c5"), c = Object(o.a)(i.default, r.b, r.c, !1, null, null, null, !1, r.a, void 0);
        e.default = c.exports;
    },
    "2ace": function(t, e, n) {
        (function(t, r) {
            var i = n("4ea4");
            Object.defineProperty(e, "__esModule", {
                value: !0
            }), e.default = void 0;
            var a = i(n("2eee")), o = i(n("9523")), c = i(n("c973"));
            function s(t, e) {
                var n = Object.keys(t);
                if (Object.getOwnPropertySymbols) {
                    var r = Object.getOwnPropertySymbols(t);
                    e && (r = r.filter(function(e) {
                        return Object.getOwnPropertyDescriptor(t, e).enumerable;
                    })), n.push.apply(n, r);
                }
                return n;
            }
            function l(t) {
                for (var e = 1; e < arguments.length; e++) {
                    var n = null != arguments[e] ? arguments[e] : {};
                    e % 2 ? s(Object(n), !0).forEach(function(e) {
                        (0, o.default)(t, e, n[e]);
                    }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(n)) : s(Object(n)).forEach(function(e) {
                        Object.defineProperty(t, e, Object.getOwnPropertyDescriptor(n, e));
                    });
                }
                return t;
            }
            e.default = {
                name: "PosterCanvas",
                props: {
                    preload: {
                        type: Boolean,
                        default: !0
                    }
                },
                data: function() {
                    return {
                        pxWidth: 750,
                        pxHeight: 1334,
                        drawArr: []
                    };
                },
                mounted: function() {
                    var t = this;
                    return (0, c.default)(a.default.mark(function e() {
                        var n;
                        return a.default.wrap(function(e) {
                            for (;;) switch (e.prev = e.next) {
                              case 0:
                                return n = 1.5, e.next = 3, t.getPoster();

                              case 3:
                                t.ctx.scale(n, n), t.drawArr = [];

                              case 5:
                              case "end":
                                return e.stop();
                            }
                        }, e);
                    }))();
                },
                methods: {
                    init: function(t) {
                        var e = this;
                        return (0, c.default)(a.default.mark(function n() {
                            var r;
                            return a.default.wrap(function(n) {
                                for (;;) switch (n.prev = n.next) {
                                  case 0:
                                    r = 1.5, e.config = t, e.canvas.width = e.config.width * r, e.canvas.height = e.config.height * r, 
                                    e.ctx.scale(r, r), e.config.backgroundColor && e.drawBackgroundColor(e.config.backgroundColor), 
                                    e.setResourceQueue();

                                  case 7:
                                  case "end":
                                    return n.stop();
                                }
                            }, n);
                        }))();
                    },
                    getPoster: function() {
                        var e = this;
                        return new Promise(function(n, i) {
                            try {
                                t.createSelectorQuery().in(e).select("#posterCanvas").fields({
                                    node: !0,
                                    size: !0
                                }).exec(function(t) {
                                    var a = t[0].node;
                                    if (a) {
                                        var o = a.getContext("2d"), c = r.getSystemInfoSync().pixelRatio;
                                        a.width = t[0].width * c, a.height = t[0].height * c, o.scale(c, c), e.ctx = o, 
                                        e.canvas = a, n();
                                    } else console.error("找不到画布节点"), i(new Error("找不到画布节点"));
                                });
                            } catch (t) {
                                t = VM2_INTERNAL_STATE_DO_NOT_USE_OR_PROGRAM_WILL_FAIL.handleException(t);
                                console.error(t), i(t);
                            }
                        });
                    },
                    setResourceQueue: function() {
                        var t = this;
                        return (0, c.default)(a.default.mark(function e() {
                            var n, r, i, o, c, s, l, u, d, h, f, x;
                            return a.default.wrap(function(e) {
                                for (;;) switch (e.prev = e.next) {
                                  case 0:
                                    n = t.config, r = n.texts, i = void 0 === r ? [] : r, o = n.images, c = void 0 === o ? [] : o, 
                                    s = n.blocks, l = void 0 === s ? [] : s, u = n.lines, d = void 0 === u ? [] : u, 
                                    (h = t.drawArr.concat(i.map(function(t) {
                                        return t.type = "text", t.zIndex = t.zIndex || 0, t;
                                    })).concat(l.map(function(t) {
                                        return t.type = "block", t.zIndex = t.zIndex || 0, t;
                                    })).concat(d.map(function(t) {
                                        return t.type = "line", t.zIndex = t.zIndex || 0, t;
                                    })).concat(c.map(function(t) {
                                        return t.type = "image", t.zIndex = t.zIndex || 0, t;
                                    }))).sort(function(t, e) {
                                        return t.zIndex - e.zIndex;
                                    }), f = 0;

                                  case 4:
                                    if (!(f < h.length)) {
                                        e.next = 22;
                                        break;
                                    }
                                    x = h[f], e.t0 = x.type, e.next = "image" === e.t0 ? 9 : "text" === e.t0 ? 12 : "block" === e.t0 ? 14 : "line" === e.t0 ? 16 : 18;
                                    break;

                                  case 9:
                                    return e.next = 11, t.drawImage(x);

                                  case 11:
                                    return e.abrupt("break", 19);

                                  case 12:
                                    return t.drawText(x), e.abrupt("break", 19);

                                  case 14:
                                    return t.drawBlock(x), e.abrupt("break", 19);

                                  case 16:
                                    return t.drawLine(x), e.abrupt("break", 19);

                                  case 18:
                                    return e.abrupt("break", 19);

                                  case 19:
                                    f++, e.next = 4;
                                    break;

                                  case 22:
                                    t.saveImage();

                                  case 23:
                                  case "end":
                                    return e.stop();
                                }
                            }, e);
                        }))();
                    },
                    drawBackgroundColor: function(t) {
                        this.ctx.save(), this.ctx.fillStyle = t, this.ctx.fillRect(0, 0, this.canvas.width, this.canvas.height), 
                        this.ctx.restore();
                    },
                    drawBlock: function(t) {
                        var e = t.text, n = t.width, r = void 0 === n ? 0 : n, i = t.height, a = t.x, o = t.y, c = t.paddingLeft, s = void 0 === c ? 0 : c, l = t.paddingRight, u = void 0 === l ? 0 : l, d = t.borderWidth, h = t.backgroundColor, f = t.borderColor, x = t.borderRadius, p = void 0 === x ? 0 : x, v = t.opacity, g = void 0 === v ? 1 : v, b = r, m = 0, w = 0;
                        if (void 0 !== e) {
                            var y = this._getTextWidth("string" == typeof e.text ? e : e.text);
                            b = y > r ? y : r, b += s + u;
                            var k = e.textAlign, I = void 0 === k ? "left" : k;
                            e.text, w = i / 2 + o, m = "left" === I ? a + s : "center" === I ? b / 2 + a : a + b - u;
                        }
                        h && (this.ctx.save(), this.ctx.globalAlpha = g, this.ctx.fillStyle = h, p > 0 ? (this._drawRadiusRect(a, o, b, i, p), 
                        this.ctx.fill()) : this.ctx.fillRect(a, o, b, i), this.ctx.restore()), d && (this.ctx.save(), 
                        this.ctx.globalAlpha = g, this.ctx.strokeStyle = f, this.ctx.lineWidth = d, p > 0 ? (this._drawRadiusRect(a, o, b, i, p), 
                        this.ctx.stroke()) : this.ctx.strokeRect(a, o, b, i), this.ctx.restore()), e && this.drawText(Object.assign(e, {
                            x: m,
                            y: w,
                            width: b
                        }));
                    },
                    drawLine: function(t) {
                        var e = t.startX, n = t.startY, r = t.endX, i = t.endY, a = t.color, o = t.width;
                        this.ctx.save(), this.ctx.beginPath(), this.ctx.strokeStyle = a, this.ctx.lineWidth = o, 
                        this.ctx.moveTo(e, n), this.ctx.lineTo(r, i), this.ctx.stroke(), this.ctx.closePath(), 
                        this.ctx.restore();
                    },
                    drawText: function(t) {
                        var e = this, n = t.x, r = t.y, i = (t.fontSize, t.color, t.baseLine), a = (t.textAlign, 
                        t.text);
                        if (t.opacity, t.width, t.lineNum, t.lineHeight, "[object Array]" === Object.prototype.toString.call(a)) {
                            var o = {
                                x: n,
                                y: r,
                                baseLine: i
                            };
                            a.forEach(function(t) {
                                o.x += t.marginLeft || 0;
                                var n = e._drawSingleText(Object.assign(t, l({}, o)));
                                o.x += n + (t.marginRight || 0);
                            });
                        } else this._drawSingleText(t);
                    },
                    drawImage: function(t) {
                        var e = this;
                        return (0, c.default)(a.default.mark(function n() {
                            var r, i, o, c, s, l, u, d, h, f, x, p, v, g, b, m, w;
                            return a.default.wrap(function(n) {
                                for (;;) switch (n.prev = n.next) {
                                  case 0:
                                    return r = t.url, i = t.x, o = t.y, c = t.borderRadius, s = void 0 === c ? 0 : c, 
                                    l = t.borderWidth, u = void 0 === l ? 0 : l, d = t.borderColor, h = t.width, f = t.height, 
                                    n.prev = 1, n.next = 4, e._loadImage(r);

                                  case 4:
                                    x = n.sent, g = x.width, b = x.height, g / b <= h / f ? (p = 0, v = (b - g / h * f) / 2) : (v = 0, 
                                    p = (g - b / f * h) / 2), m = g - 2 * p, w = b - 2 * v, e.ctx.save(), s > 0 ? (e._drawRadiusRect(i, o, h, f, s), 
                                    e.ctx.strokeStyle = "rgba(255,255,255,0)", e.ctx.stroke(), e.ctx.clip(), e.ctx.drawImage(x, p, v, m, w, i, o, h, f), 
                                    u > 0 && (e.ctx.strokeStyle = d, e.ctx.lineWidth = u, e.ctx.stroke())) : e.ctx.drawImage(x, p, v, m, w, i, o, h, f), 
                                    e.ctx.restore(), n.next = 18;
                                    break;

                                  case 15:
                                    n.prev = 15, n.t0 = n.catch(1), console.error("图片绘制失败", n.t0, t);

                                  case 18:
                                  case "end":
                                    return n.stop();
                                }
                            }, n, null, [ [ 1, 15 ] ]);
                        }))();
                    },
                    saveImage: function(t) {
                        var e = this;
                        r.canvasToTempFilePath({
                            canvas: this.canvas,
                            success: function(n) {
                                t && t(n.tempFilePath), e.$emit("success", n.tempFilePath);
                            },
                            fail: function(t) {
                                e.$emit("fail", t);
                            }
                        });
                    },
                    measureText: function(t, e) {
                        t.x, t.y;
                        var n = t.fontSize, r = void 0 === n ? 24 : n, i = t.color, a = t.baseLine, o = t.textAlign, c = void 0 === o ? "left" : o, s = t.text, l = t.opacity, u = void 0 === l ? 1 : l, d = (t.textDecoration, 
                        t.width), h = t.lineNum, f = void 0 === h ? 1 : h, x = t.lineHeight, p = void 0 === x ? 0 : x, v = t.fontWeight, g = void 0 === v ? "normal" : v, b = t.fontStyle, m = void 0 === b ? "normal" : b, w = t.fontFamily, y = void 0 === w ? "sans-serif" : w;
                        this.ctx.save(), this.ctx.font = "".concat(m, " ").concat(g, " ").concat(r, "px ").concat(y), 
                        this.ctx.globalAlpha = u, this.ctx.fillStyle = i, this.ctx.textAlign = c, this.ctx.textBaseline = a;
                        var k = this.ctx.measureText(s).width, I = [];
                        if (k > d) {
                            for (var P = "", O = 1, S = 0; S <= s.length - 1; S++) P += s[S], this.ctx.measureText(P).width >= d ? (O === f && S !== s.length - 1 && (P = "".concat(P.substring(0, P.length - 1), "...")), 
                            ("auto" === f || O <= f) && I.push(P.substring(0, P.length - 1)), P = s[S], O++) : ("auto" === f || O <= f) && S === s.length - 1 && I.push(P);
                            k = d;
                        } else I.push(s);
                        var T = {
                            width: k,
                            line: I.length,
                            height: (p || r) * I.length
                        };
                        return e && e(I, T), this.ctx.restore(), T;
                    },
                    _getTextWidth: function(t) {
                        var e = this, n = [];
                        "[object Object]" === Object.prototype.toString.call(t) ? n.push(t) : n = t;
                        var r = 0;
                        return this.ctx.save(), n.forEach(function(t) {
                            var n = t.fontStyle, i = void 0 === n ? "normal" : n, a = t.fontSize, o = void 0 === a ? 24 : a, c = t.fontWeight, s = void 0 === c ? "normal" : c, l = t.fontFamily, u = void 0 === l ? "sans-serif" : l, d = t.text, h = t.marginLeft, f = void 0 === h ? 0 : h, x = t.marginRight, p = void 0 === x ? 0 : x;
                            e.ctx.font = "".concat(i, " ").concat(s, " ").concat(o, "px ").concat(u), r += e.ctx.measureText(d).width + f + p;
                        }), this.ctx.restore(), r;
                    },
                    _drawSingleText: function(t) {
                        var e = this, n = t.x, r = t.y, i = t.fontSize, a = void 0 === i ? 24 : i, o = (t.color, 
                        t.baseLine, t.textAlign, t.text, t.opacity, t.width, t.lineNum, t.lineHeight), c = void 0 === o ? 0 : o;
                        return (t.fontWeight, t.fontStyle, t.fontFamily, this.measureText(t, function(t) {
                            t.forEach(function(t, i) {
                                e.ctx.fillText(t, n, r + (c || a) * i);
                            });
                        })).width;
                    },
                    _drawRadiusRect: function(t, e, n, r, i) {
                        var a = i / 2;
                        this.ctx.beginPath(), this.ctx.moveTo(t + a, e), this.ctx.lineTo(t + n - a, e), 
                        this.ctx.arc(t + n - a, e + a, a, 2 * Math.PI * (3 / 4), 2 * Math.PI * 1), this.ctx.lineTo(t + n, e + r - a), 
                        this.ctx.arc(t + n - a, e + r - a, a, 0, 2 * Math.PI * (1 / 4)), this.ctx.lineTo(t + a, e + r), 
                        this.ctx.arc(t + a, e + r - a, a, 2 * Math.PI * (1 / 4), 2 * Math.PI * .5), this.ctx.lineTo(t, e + a), 
                        this.ctx.arc(t + a, e + a, a, 2 * Math.PI * .5, 2 * Math.PI * (3 / 4));
                    },
                    _loadImage: function(t) {
                        var e = this;
                        return new Promise(function(n, r) {
                            var i = e.canvas.createImage();
                            i.onload = function() {
                                n(i);
                            }, i.onerror = function(e) {
                                console.error(e), r(new Error("fail to fetch image from: ".concat(t)));
                            }, i.src = t;
                        });
                    }
                }
            };
        }).call(this, n("543d").default, n("bc2e").default);
    },
    "5ff5": function(t, e, n) {
        n.d(e, "b", function() {
            return r;
        }), n.d(e, "c", function() {
            return i;
        }), n.d(e, "a", function() {});
        var r = function() {
            this.$createElement;
            this._self._c;
        }, i = [];
    },
    "859f": function(t, e, n) {
        n.r(e);
        var r = n("2ace"), i = n.n(r);
        for (var a in r) [ "default" ].indexOf(a) < 0 && function(t) {
            n.d(e, t, function() {
                return r[t];
            });
        }(a);
        e.default = i.a;
    },
    b446: function(t, e, n) {
        var r = n("1ef0");
        n.n(r).a;
    }
} ]), (global.webpackJsonp = global.webpackJsonp || []).push([ "pages/components/poster/index-create-component", {
    "pages/components/poster/index-create-component": function(t, e, n) {
        n("543d").createComponent(n("2818"));
    }
}, [ [ "pages/components/poster/index-create-component" ] ] ]);